﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZenSystemService.Api.Migrations
{
    /// <inheritdoc />
    public partial class TraingItemProductType_Temp3 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TrainingItemProductTypes",
                columns: table => new
                {
                    TrainingItemProductType1Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    TraingingItemId = table.Column<int>(type: "int", nullable: false),
                    TrainingItemId = table.Column<int>(type: "int", nullable: false),
                    ProductTypeId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TrainingItemProductTypes", x => x.TrainingItemProductType1Id);
                    table.ForeignKey(
                        name: "FK_TrainingItemProductTypes_ProductTypes_ProductTypeId",
                        column: x => x.ProductTypeId,
                        principalTable: "ProductTypes",
                        principalColumn: "ProductTypeId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TrainingItemProductTypes_TrainingItems_TrainingItemId",
                        column: x => x.TrainingItemId,
                        principalTable: "TrainingItems",
                        principalColumn: "TrainingItemId",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingItemProductTypes_ProductTypeId",
                table: "TrainingItemProductTypes",
                column: "ProductTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingItemProductTypes_TrainingItemId",
                table: "TrainingItemProductTypes",
                column: "TrainingItemId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TrainingItemProductTypes");
            
        }
    }
}
